﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ProjectDeal.Helpers;
using ProjectDeal.Models;

namespace ProjectDeal.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/
        db_Kayleehouse db = new db_Kayleehouse();
        //Trang Chu
        public ActionResult Index(string page)
        {
            int CurrPage = 1;
            if (page!= null)
	        {
                CurrPage = Int32.Parse(page);
	        }
           
            //Lay danh sach phan trang deal
            //Madeal = -1 thi lay toan bo khong chia category
            
            var lsDeal = db.Deal_GetDealPhanTrang(CurrPage,9,5).ToList();
            var totalRecord = (from b in db.Deals
                               where b.TrangThaiDeal == true
                               select b.MaDeal).Count();
            string pt = db.DealGetDealPhantrangView(totalRecord,CurrPage, 5,9).Single().ToString();
            ViewBag.PagingView = pt;
            return View(lsDeal);
        }

    }
}
